home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / usr_-_Usr_Files / INCLUDE / PRINTF.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  5KB  |  142 lines

  1. /* Copyright (C) 1991, 1992, 1993, 1995, 1996 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18.  
  19. #ifndef    _PRINTF_H
  20.  
  21. #define    _PRINTF_H    1
  22. #include <features.h>
  23.  
  24. __BEGIN_DECLS
  25.  
  26. #define    __need_FILE
  27. #include <stdio.h>
  28. #define    __need_size_t
  29. #include <stddef.h>
  30.  
  31. #if 0
  32. struct printf_info
  33. {
  34.   int prec;            /* Precision.  */
  35.   int width;            /* Width.  */
  36.   unsigned char spec;        /* Format letter.  */
  37.   unsigned int is_long_double:1;/* L flag.  */
  38.   unsigned int is_short:1;    /* h flag.  */
  39.   unsigned int is_long:1;    /* l flag.  */
  40.   unsigned int alt:1;        /* # flag.  */
  41.   unsigned int space:1;        /* Space flag.  */
  42.   unsigned int left:1;        /* - flag.  */
  43.   unsigned int showsign:1;    /* + flag.  */
  44.   unsigned int group:1;        /* ' flag.  */
  45.   char pad;            /* Padding character.  */
  46. };
  47. #else
  48. struct printf_info
  49. {
  50.   int prec;            /* Precision.  */
  51.   int width;            /* Width.  */
  52.   unsigned char spec;        /* Format letter.  */
  53.   unsigned int is_long_double;    /* L flag.  */
  54.   unsigned int is_short;    /* h flag.  */
  55.   unsigned int is_long;        /* l flag.  */
  56.   unsigned int alt;        /* # flag.  */
  57.   unsigned int space;        /* Space flag.  */
  58.   unsigned int left;        /* - flag.  */
  59.   unsigned int showsign;    /* + flag.  */
  60.   unsigned int group;        /* ' flag.  */
  61.   char pad;            /* Padding character.  */
  62. };
  63. #endif
  64.  
  65. /* Type of a printf specifier-handler function.
  66.    STREAM is the FILE on which to write output.
  67.    INFO gives information about the format specification.
  68.    ARGS is a vector of pointers to the argument data;
  69.    the number of pointers will be the number returned
  70.    by the associated arginfo function for the same INFO.
  71.  
  72.    The function should return the number of characters written,
  73.    or -1 for errors.  */
  74.  
  75. typedef int (*printf_function) __P ((FILE *__stream,
  76.                      __const struct printf_info *__info,
  77.                      __const void **__const __args));
  78.  
  79. /* Type of a printf specifier-arginfo function.
  80.    INFO gives information about the format specification.
  81.    N, ARGTYPES, and return value are as for printf_parse_format.  */
  82.  
  83. typedef int (*printf_arginfo_function) __P ((__const struct printf_info *__info,
  84.                          size_t __n,
  85.                          int *__argtypes));
  86.  
  87.  
  88. /* Register FUNC to be called to format SPEC specifiers; ARGINFO must be
  89.    specified to determine how many arguments a SPEC conversion requires and
  90.    what their types are, even if your program never calls
  91.    `parse_printf_format'.  */
  92.  
  93. extern int register_printf_function __P ((int __spec,
  94.                       printf_function __func,
  95.                       printf_arginfo_function __arginfo));
  96.  
  97.  
  98. /* Parse FMT, and fill in N elements of ARGTYPES with the
  99.    types needed for the conversions FMT specifies.  Returns
  100.    the number of arguments required by FMT.
  101.  
  102.    The ARGINFO function registered with a user-defined format is passed a
  103.    `struct printf_info' describing the format spec being parsed.  A width
  104.    or precision of INT_MIN means a `*' was used to indicate that the
  105.    width/precision will come from an arg.  The function should fill in the
  106.    array it is passed with the types of the arguments it wants, and return
  107.    the number of arguments it wants.  */
  108.  
  109. extern size_t parse_printf_format __P ((__const char *__fmt,
  110.                     size_t __n,
  111.                     int *__argtypes));
  112.  
  113.  
  114. /* Codes returned by `parse_printf_format' for basic types.
  115.  
  116.    These values cover all the standard format specifications.
  117.    Users can add new values after PA_LAST for their own types.  */
  118.  
  119. enum
  120. {                /* C type: */
  121.   PA_INT,            /* int */
  122.   PA_CHAR,            /* int, cast to char */
  123.   PA_STRING,            /* const char *, a '\0'-terminated string */
  124.   PA_POINTER,            /* void * */
  125.   PA_FLOAT,            /* float */
  126.   PA_DOUBLE,            /* double */
  127.   PA_LAST
  128. };
  129.  
  130. /* Flag bits that can be set in a type returned by `parse_printf_format'.  */
  131. #define    PA_FLAG_MASK        0xff00
  132. #define    PA_FLAG_LONG_LONG    (1 << 8)
  133. #define    PA_FLAG_LONG_DOUBLE    PA_FLAG_LONG_LONG
  134. #define    PA_FLAG_LONG        (1 << 9)
  135. #define    PA_FLAG_SHORT        (1 << 10)
  136. #define    PA_FLAG_PTR        (1 << 11)
  137.  
  138.  
  139. __END_DECLS
  140.  
  141. #endif /* printf.h  */
  142.